// 极简文章数据
const articles = [
    {
        id: 1,
        title: "极简主义的生活方式",
        excerpt: "探索如何通过减少物质负担和精神杂念，获得更多内心的平静与生活的满足感。",
        date: "2023-10-20",
        category: "生活"
    },
    {
        id: 2,
        title: "阅读的意义",
        excerpt: "在信息过载的时代，深度阅读如何帮助我们保持思考的深度与独立性。",
        date: "2023-10-15",
        category: "阅读"
    },
    {
        id: 3,
        title: "简洁设计的原则",
        excerpt: "少即是多。探索简洁设计背后的哲学与实践方法。",
        date: "2023-10-10",
        category: "设计"
    },
    {
        id: 4,
        title: "数字极简主义",
        excerpt: "如何减少数字干扰，重获注意力与时间的主控权。",
        date: "2023-10-05",
        category: "科技"
    }
];

// DOM加载完成后执行
document.addEventListener('DOMContentLoaded', function() {
    // 加载文章
    loadArticles();
    
    // 平滑滚动
    setupSmoothScroll();
});

// 加载文章到列表
function loadArticles() {
    const articlesList = document.getElementById('articlesList');
    
    articles.forEach(article => {
        const articleElement = createArticleElement(article);
        articlesList.appendChild(articleElement);
    });
}

// 创建文章元素
function createArticleElement(article) {
    const articleItem = document.createElement('div');
    articleItem.className = 'article-item';
    
    articleItem.innerHTML = `
        <h3 class="article-title">
            <a href="#article-${article.id}">${article.title}</a>
        </h3>
        <div class="article-meta">${article.date} · ${article.category}</div>
        <p class="article-excerpt">${article.excerpt}</p>
    `;
    
    return articleItem;
}

// 设置平滑滚动
function setupSmoothScroll() {
    const navLinks = document.querySelectorAll('.nav-menu a');
    
    navLinks.forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            
            const targetId = this.getAttribute('href');
            const targetElement = document.querySelector(targetId);
            
            if (targetElement) {
                window.scrollTo({
                    top: targetElement.offsetTop - 20,
                    behavior: 'smooth'
                });
            }
        });
    });
}